<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<script>
	function doModify(adminId){
		var authors = "";
		$(".checkbox_" + adminId + ":checked").each(function(){
			authors +=  $(this).val() + ",";
		});
		if(authors != ""){
			authors = authors.substring(0,authors.length - 1);
		}else{
			alert("请你至少选择一项权限");
			return;
		}		
		
		$("#author_" + adminId).val(authors);
		$("#form_" + adminId).attr("action","modifyAdmin.do");
		$("#form_" + adminId).submit();
	}
	
	function doDelete(adminId,username){
		if(confirm("你确定要删除用户[" + username + "]吗?")){
			$("#form_" + adminId).attr("action","deleteAdmin.do");
			$("#form_" + adminId).submit();
		}
	}
	
	function doAdd(){
		var authors = "";
		$(".checkbox_new:checked").each(function(){
			authors +=  $(this).val() + ",";
		});
		if(authors != ""){
			authors = authors.substring(0,authors.length - 1);
		}else{
			alert("请你至少选择一项权限");
			return;
		}
		
		$("#author_new").val(authors);
		$("#form_new").submit();
	}
</script>
<%-- <form class="form-inline" action="" method="get">
  <div class="datepicker input-append">
    <input data-format="yyyy-MM-dd" type="text" value="${selectDate}" name="selectDate"></input>
    <span class="add-on">
      <i data-time-icon="icon-time" data-date-icon="icon-calendar">
      </i>
    </span>
  </div>
  <button type="submit" class="btn">查询</button>&nbsp;
  <button type="button" class="btn" id="lookChart" onclick="seePic();">查看图表</button>
  &nbsp;<span>总记录数：${onlineCount.allCount}</span>
</form>--%>
<table class="table table-bordered">
  <thead>
    <tr>	 	 	 	 	 	 	 							 	
      <th>用户名</th>
      <th>密码 </th>
      <th>拥有权限</th>
      <th>操作</th>
    </tr>
  </thead>
  <tbody>
  <c:forEach var="m" items="${list}">
  <form id="form_${m.id}" class="form-inline" action="" method="get">
    <tr>
      <td>${m.username}</td>
      <input type="hidden" name="username" value="${m.username}"/>
      <td>******</td>
      <input type="hidden" name="password" value="${m.password}"/>
      <td>
      <c:forEach var="k" items="${items.keySet()}">
      	<label class="checkbox-inline">
 		 <input type="checkbox" class="checkbox_${m.id}" ${m.ids.contains(k) ? 'checked' : ''} value="${k}"> ${items.get(k)}
		</label>
	  </c:forEach>
	  <input type="hidden" id="author_${m.id}" name="authors" value=""/>
      </td>
      <td><button type="button" class="btn" onclick="doModify('${m.id}');">修改</button><button type="button" class="btn" onclick="doDelete('${m.id}','${m.username}');">删除</button></td>
    </tr>
   </form>
  </c:forEach>
  <form id="form_new" class="form-inline" action="addAdmin.do" method="get">
  <tr>
  	<td>
  		<input type="text" name="username" value=""></input>
  	</td>
  	<td>
  		<input type="text" name="password" value=""></input>
  	</td>
  	<td>
  		 <c:forEach var="k" items="${items.keySet()}">
      		<label class="checkbox-inline">
 		 	<input type="checkbox" class="checkbox_new" value="${k}"> ${items.get(k)}
			</label>
	    </c:forEach>
  	</td>
  	<input type="hidden" name="author_new" id="author_new" value=""/>
  	<td>
  		<button type="button" class="btn" onclick="doAdd();">增加</button>
  	</td>
  </tr>
  </form>
 	</tbody>
</table>
功能说明：<br/>
1、拥有权限，根据现在的大模块分类:<br/>
	运营数据<br/>
	用户行为分析<br/>
	消耗统计<br/>
	功能模块操作<br/>
	游戏管理<br/>
	可疑行为<br/>
	财务查询<br/>
	高级管理员操作<br/>
2、列表最后一样用户添加管理员，只要在空白地方填写用户名和昵称，然后再勾选权限，点添加即可添加管理员
</body>
</html>